package com.basics.service.impl;

import com.basics.mapper.UserAdminMapper;
import com.basics.model.UserAdmin;
import com.basics.service.UserAdminService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;


@Service
@Transactional(rollbackFor = Exception.class)
public class UserAdminServiceImpl implements UserAdminService {

    @Resource
    private UserAdminMapper userAdminMapper;

    public UserAdmin getUserByUserNameAndPassWord(String userAdminName, String passWord) {

        return userAdminMapper.UserAdminLogin(userAdminName,passWord);

    }

    public UserAdmin checkPhone(String mobile) {

            return userAdminMapper.checkPhone(mobile);

    }

    @Override
    public UserAdmin checkloginName(String l_loginname) {
        return userAdminMapper.checkloginName(l_loginname);
    }

    @Override
    public Integer adminUserRegister(UserAdmin userAdmin) {
        return userAdminMapper.insertSelective(userAdmin);
    }

    @Override
    public Integer updateLoginTime(Date lastLoginTime, Date loginTime, String userName) {
        return userAdminMapper.updateLoginTime(lastLoginTime,loginTime,userName);
    }

    //根据登录名查询该账号是否被禁用
    @Override
    public Integer getUserState(String username) {
        return userAdminMapper.getUserState(username);
    }

    @Override
    public UserAdmin selectByUserName(String username) {

        return userAdminMapper.selectByUserName(username);
    }

    @Override
    public Integer ResetPassword(String phone, String Psaaword) {
        return  userAdminMapper.ResetPassword(phone,Psaaword);
    }


}
